<!DOCTYPE html>
<html lang="en" style="opacity: 1; font-size: 26.6666px;">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="description" content="ncov疫情查看">
		<meta name="keywords" content="">
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
		<meta name="renderer" content="webkit">
		<meta name="format-detection" content="telphone=no,email=no,address=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta http-equiv="x-dns-prefetch-control" content="on">
		<title>{$ncovsetres['sharetitle']}</title>
		<script src="https://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
		<script src="https://wuhoucdn.oss-cn-hangzhou.aliyuncs.com/common/jquery-3.2.1.min.js"></script>
		{if !empty($ncovsetres['baiduapi'])}
		<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak={$ncovsetres['baiduapi']}"></script>
        <script type="text/javascript" src="https://api.map.baidu.com/getscript?v=2.0&ak={$ncovsetres['baiduapi']}&services=&t=20200103103842"></script>
		{else}
		<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=5WR8oFDG72Gg0dskDs2w9yfGKpCvH80r"></script>
        <script type="text/javascript" src="https://api.map.baidu.com/getscript?v=2.0&ak=5WR8oFDG72Gg0dskDs2w9yfGKpCvH80r&services=&t=20200103103842"></script>
		{/if}
        
        <script src="https://mapv.baidu.com/build/mapv.min.js"></script>
	</head>
	<script type="text/javascript">
        /*框架自带js判断*/
        if(navigator.appName == 'Microsoft Internet Explorer'){
            if(navigator.userAgent.indexOf("MSIE 5.0")>0 || navigator.userAgent.indexOf("MSIE 6.0")>0 || navigator.userAgent.indexOf("MSIE 7.0")>0) {
                alert('您使用的 IE 浏览器版本过低, 推荐使用 Chrome 浏览器或 IE8 及以上版本浏览器.');
            }
        }
        window.sysinfo = {
            {if !empty($_W['uniacid'])}'uniacid': '{$_W['uniacid']}',{/if}
            {if !empty($_W['acid'])}'acid': '{$_W['acid']}',{/if}{if !empty($_W['openid'])}'openid': '{$_W['openid']}',{/if}
            {if !empty($_W['uid'])}'uid': '{$_W['uid']}',{/if}
            'siteroot': '{$_W['siteroot']}',
            'siteurl': '{$_W['siteurl']}',
            'attachurl': '{$_W['attachurl']}',
            'attachurl_local': '{$_W['attachurl_local']}',
            'attachurl_remote': '{$_W['attachurl_remote']}',
            {if defined('MODULE_URL')}'MODULE_URL': '{MODULE_URL}',{/if}
            'cookie' : {'pre': '{$_W['config']['cookie']['pre']}'}
        };
        /*微信 jssdk 加载*/
        // jssdk config 对象
        jssdkconfig = {php echo json_encode($_W['account']['jssdkconfig']);} || {};
        // 是否启用调试
        jssdkconfig.debug = false;
        jssdkconfig.jsApiList = [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'getLocation'
        ];
    </script>
	<style type="text/css">
		*{margin:0;padding:0}.place .info{height:38px;line-height:38px;margin:auto;overflow:hidden;background:#f8f8f8;padding:0 25px 0 15px;border-radius:12px;font-size:16px;color:#222;position:relative;font-weight:400}.bodys{font-size:12px;color:#888}#r-result{position:fixed;left:0;right:0;top:0;margin:15px;z-index:100}#suggestId{width:100%;height:40px;padding:5px;font-size:14px;background:#fff url("/addons/{php echo $this->moduleName;}/template/mobile/styles/search.png") no-repeat 10px center;background-size:20px 20px;padding-left:40px;border:1px solid rgba(170,170,170,1);opacity:.9;border-radius:20px;display:-webkit-box;box-sizing:border-box;color:#353535}input::placeholder{color:#aaa}.tps{font-size:18px;color:blue;text-align:center}.windowInfo{position:fixed;bottom:0;left:0;right:0;font-size:24px;padding-top:15px;text-align:center;color:#666;border-top-left-radius:20px;border-top-right-radius:20px;background-color:#fff}.close{position:absolute;right:0;top:10px;color:#888;font-size:14px;text-align:right;padding:10px;width:10px;height:10px;background:url("/addons/{php echo $this->moduleName;}/template/mobile/styles/icon-close.png") no-repeat center center;background-size:40% 40%}#infoMsg{padding:0 10px;font-size:16px;text-align:left}.info_title{font-weight:bold;color:#000}.info_title span{font-weight:normal}.info_subtype{font-size:13px;color:#888;background-repeat:no-repeat;background-position:left center;background-size:10px 10px;padding-left:15px;margin-top:2px}.info_more{margin-top:20px;display:flex;color:#000;font-size:16px}.info_more span{display:block;width:50%;text-align:center}.info_subtype_pos{background-image:url("/addons/{php echo $this->moduleName;}/template/mobile/styles/users-pos.png")}.info_subtype_timer{background-image:url("/addons/{php echo $this->moduleName;}/template/mobile/styles/users-timer.png")}.info_subtype_name{background-image:url("/addons/{php echo $this->moduleName;}/template/mobile/styles/users-name.png")}.source{font-size:12px;color:#888;text-align:center;margin-top:10px}.infoFooter{height:70px;background:#f7f7f7;display:flex;align-items:center;justify-content:space-around;margin:20px 15px 15px 15px}.footertext{font-size:12px;color:#000}.qcord{height:56px;max-width: 100px;}
	</style>
	<body>
        <div class="container" id="data">
            <div id="r-result"><input type="text" id="suggestId" value="" placeholder="输入小区/街道名称查询" autocomplete="off"></div>
        
            <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:200px;height:auto; display:none;"></div>

            <div style="position: fixed;left: 0px;right: 0px;bottom: 0px;top: 0px">
                <div id="bdmap" style="width: 100%; height: 100%; overflow: hidden; position: relative; z-index: 0; background-color: rgb(243, 241, 236); color: rgb(0, 0, 0); text-align: left;"></div>
            </div>
            <div id="windowInfo" class="windowInfo" style="display: block;">
                <div class="close" onclick="hidewindow()"></div>
                <div id="infoMsg"><div class="info_title">离我最近的疫情病例：<span style="color: #FF5050">0公里</span></div><div class="info_subtype info_subtype_pos"></div><div class="info_more"><span>3公里内有0个病例</span>|<span>5公里内有0个病例</span></div></div>
                <p class="source">数据来源：{$ncovsetres["datafrom"]}</p>
                <div class="infoFooter">
                    <img src="{$logo}" class="qcord">
                    <div class="footertext">
                        <div style="text-align: left">
                            长按识别二维码 &gt;&gt;&gt;<br>
                            订阅最新消息
                        </div>
                    </div>
                    <img src="{$wxlogo}" class="qcord">
                </div>
            </div>
        </div>
        
        <script>
            function showWindow(html){
                document.getElementById("infoMsg").innerHTML = html;
                document.getElementById("windowInfo").style.display = "block";
            }
            function hidewindow(){
                document.getElementById("infoMsg").innerHTML  = '';
                document.getElementById("windowInfo").style.display = "none";
            }
            function initMap(datas,locationscy){
                var map = new BMap.Map("bdmap");
                var point = new BMap.Point("112.471497", "34.603587");
                var users=[];
                map.centerAndZoom(point, 14);
        
        
                map.enableScrollWheelZoom();
                var geolocation = new BMap.Geolocation();
        
                // 开启SDK辅助定位
                geolocation.enableSDKLocation();
        
                function myFun(item,p){
                    // opts.title="病例";
                    // opts.height=150;
                    var s ='<div class="info_title">疫情病例：</div><div class="info_subtype info_subtype_name">'+item.name+'</div><div class="info_subtype info_subtype_timer">发现日期：'+item.date+'</div><div class="info_subtype info_subtype_pos">'+item.address+'</div>';
        
                    var p= new BMap.Point( p[0], p[1]);
                    // 重新定位
                    map.panTo(p, true);
                    // map.centerAndZocenterAndZoomom(p, 14);
                    showWindow(s);
                    // var infoWindow = new BMap.InfoWindow(s, opts);
                    // map.openInfoWindow(infoWindow,p);
                    // console.log(p)
                    // map.itemAndZoom(item.coordinates, 7);
        
        
                }
                var geoc = new BMap.Geocoder();
                var  xpoints=[];
        
        
                var options = {
                    draw: 'heatmap',
                    size: 900,
                    unit: 'm',
                    gradient: { // 热力图渐变色
                        0.1: "rgb(0,0,100)",
                        0.15: "rgb(0,0,150)",
                        0.20: "rgb(0,0,200)",
                        0.25: "rgb(0,0,255)",
                        0.3: "rgb(0,100,0)",
                        0.35: "rgb(0,150,0)",
                        0.40: "rgb(0,200,0)",
                        0.45: "rgb(0,255,0)",
                        0.50: "rgb(239,98,146)",
                        0.60: "rgb(249,222,61)",
                        0.85: "yellow",
                        1.0: "rgb(220,0,0)"
                    },
                    max: 1.5, // 最大权重值
                    methods: { // 一些事件回调函数
                        click: function(item) { //
                            // console.log(item);
                            // myFun(item.data,item.geometry.coordinates)
                        },
                    }
                }
        
                function keys(a,b){
        
                    return a.toString().substr(0,11)+","+b.toString().substr(0,16);
                }
                function setPoint(point,item){
                    num = num - 1;
                    // console.log('...获取point'+point)
                    if (point) {
                        users.push({point: point, item: item});
                        xpoints.push({
                            "geometry": {"type": "Point", "coordinates": Object.values(point)},
                            "properties": {"count": 1},
                            data: item
                        })
        
                        // console.log(num)
                        if (num == 0) {
                            var dataSet = new mapv.DataSet(xpoints);
                            // console.log(dataSet)
                            var mapvsharp = new mapv.baiduMapLayer(map, dataSet, options);
                            map.centerAndZoom(point, 14);
        
                            geolocation.getCurrentPosition(function (r) {
                            	console.log(locationscy)
						        
						        r.point.lng = locationscy.lng
						        r.point.lat = locationscy.lat
								// console.log(slng,slat)
                                if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                                    let mymarker = new BMap.Marker(r.point);
                                    map.addOverlay(mymarker);
                                    nearBy(r.point)
                                } else {
                                    alert('failed' + this.getStatus());
                                }
                            });
        
                        }
                        point.lng += Math.random() * 0.00005;
                        point.lat += Math.random() * 0.0005;
                        // console.log(point)
                        var mk = new BMap.Marker(point)
                        console.log(item.name,item.date,item.address,point.lat,point.lng)
                        map.addOverlay(mk);
                        var iconPath = '/addons/{php echo $this->moduleName;}/template/mobile/styles/pos.png?1.0'; //这个是你要显示坐标的图片的相对路径-->
                        replaceIcon(iconPath, mk, 40, 40);
                        mk.addEventListener("click", function () {
                            myFun(item, Object.values(point))
                        });
        
                    }
                }
                var num=datas.length
                for (let i in datas) {
                    let item = datas[i]
                    // console.log(item,i, num - 1)
                    if(item.position){
                        let position_str = new BMap.Point(Number(item.position.lng), Number(item.position.lat))
                        setPoint(position_str,item)
                    }else{
                        geoc.getPoint(item.address, function (point) {
                                setPoint(point,item)
                            },
                            "洛阳市");// 地址所在城市名
                    }
                }
                    function nearBy(p){
                        var res={}
                        for (var i = users.length - 1; i >= 0; i--) {
        
                            res[parseFloat(map.getDistance(users[i].point,p)) ]=users[i];
                        }
        
        
                        // console.log(res)
                        var vars=Object.keys(res).sort((a,b)=>{ return parseFloat(a)-parseFloat(b) });
        
        
                        var m3=m5=0;
                        for(let a of vars ){
        
                            if(a<3000){
                                m3+=1;
                                m5+=1;
                            }else if(a<5000){
                                m5+=1;
        
                            }
                        }
        
                        // console.log(vars)
                        var x=vars[0];
        
                        var one= res[x]
                        var s = `<div class="info_title">离我最近的疫情病例：<span style="color: #FF5050">${(x/1000).toFixed(2)}公里</span></div><div class="info_subtype info_subtype_pos">${one.item.address}</div><div class="info_more"><span>3公里内有${m3}个病例</span>|<span>5公里内有${m5}个病例</span></div>`
                        console.log('in...离我最近')
                        // opts.title="周边疫情";
                        // opts.height=340;
                        // map.panTo(p, true);
                        map.centerAndZoom(p, 14);
                        showWindow(s)
                        // var infoWindow = new BMap.InfoWindow(s, opts);
                        // map.openInfoWindow(infoWindow,p);
                    }
        
                    function G(id) {
                        return document.getElementById(id);
                    }
        
                    function replaceIcon(iconPath, marker, sizeW, sizeH) {
                        map.removeOverlay(marker);
                        var icons = iconPath; //这个是你要显示坐标的图片的相对路径-->
                        var icon = new BMap.Icon(icons, new BMap.Size(sizeW, sizeH)); //显示图标大小-->
                        marker.setIcon(icon);//设置标签的图标为自定义图标-->
                        map.addOverlay(marker);//将标签添加到地图中去-->
                    }
                    var acInput = new BMap.Autocomplete(    //建立一个自动完成的对象
                        {"input" : "suggestId"
                            ,"location" : point
                        });
        
                    acInput.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
                        var str = "";
                        var _value = e.fromitem.value;
                        var value = "";
                        if (e.fromitem.index > -1) {
                            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
                        }
                        str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
        
                        value = "";
                        if (e.toitem.index > -1) {
                            _value = e.toitem.value;
                            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
                        }
                        str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
                        G("searchResultPanel").innerHTML = str;
                    });
        
                    var myValue;
                    acInput.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
                        var _value = e.item.value;
                        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
                        G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
        
                        setPlace();
                        document.querySelector("#suggestId").blur();
        
                    });
        
                    function setPlace(){
        
                        function myFun(){
                            G("searchResultPanel").style.display = "none";
                            var pp = local.getResults().getPoi(0).point;    //
                            nearBy(pp)
                        }
                        var local = new BMap.LocalSearch(map, { //智能搜索
                            onSearchComplete: myFun
                        });
                        local.search(myValue);
                    }
        
                    var navigationControl = new BMap.NavigationControl({
                        // 靠左上角位置
                        anchor: BMAP_ANCHOR_TOP_LEFT,
                        offset: new BMap.Size(20,70),
                        // LARGE类型
                        type: BMAP_NAVIGATION_CONTROL_LARGE,
                        // 启用显示定位
                        enableGeolocation: true
                    });
                    map.addControl(navigationControl);
                    // 添加定位控件
                    var geolocationControl = new BMap.GeolocationControl();
                    geolocationControl.addEventListener("locationSuccess", function(e){
                        // 定位成功事件
                        nearBy(e.point)
                    });
                    geolocationControl.addEventListener("locationError",function(e){
                        // 定位失败事件
                        alert(e.message);
                    });
                    map.addControl(geolocationControl);
        
                }
        
        </script>
        
        <!--// 疫情病例具体数据-->
        <script>
            // window.onload=function () {
            //     initMap({$conv_json});
            // }
        </script>
        
        <script type="text/javascript">
			$(function(){
				wx.config(jssdkconfig);
				var $_share = {php echo json_encode($_share);};
				if(typeof sharedata == 'undefined'){
					sharedata = $_share;
				} else {
					sharedata['title'] = sharedata['title'] || $_share['title'];
					sharedata['desc'] = sharedata['desc'] || $_share['desc'];
					sharedata['link'] = sharedata['link'] || $_share['link'];
					sharedata['imgUrl'] = sharedata['imgUrl'] || $_share['imgUrl'];
				}
				console.log(sharedata)
				if(sharedata.imgUrl == ''){
					var _share_img = $('body img:eq(0)').attr("src");
					if(_share_img){
						sharedata['imgUrl'] = util.tomedia(_share_img);
					}
				}
				if(sharedata.imgUrl == ""){
					sharedata.imgUrl = window.sysinfo.attachurl + 'images/global/wechat_share.jpg';
				}
				if(sharedata.desc == ''){
					var _share_content = util.removeHTMLTag($('body').html());
					if(typeof _share_content == 'string'){
						sharedata.desc = _share_content.replace($_share['title'], '')
					}
				}
				
				translateCallback = function (data){
			      if(data.status === 0) {
			        initMap({$conv_json},data.points[0])
			        // alert(666)
			      }
			    }
				
				wx.ready(function () {
					wx.onMenuShareAppMessage(sharedata);
					wx.onMenuShareTimeline(sharedata);
					wx.onMenuShareQQ(sharedata);
					wx.onMenuShareWeibo(sharedata);
					wx.checkJsApi({
	                    jsApiList: [
	                        'getLocation'
	                    ] ,
	                    success : function (res) {
	                        if (res.checkResult.getLocation == false) {
	                            alert('你的微信版本太低，不支持微信JS接口，请升级到最新的微信版本！');
	                            return;
	                        }
	                    }
	                })
					wx.getLocation({
                        type: 'wgs84',		// 坐标类型 默认wgs84
                        success: function (res) {
                        	var ggPoint = new BMap.Point(res.longitude,res.latitude);
							var convertor = new BMap.Convertor();
					        var pointArr = [];
					        pointArr.push(ggPoint);
					        convertor.translate(pointArr, 1, 5, translateCallback)
                        },
                        fail:function(res){
                        	alert('请开启定位授权！');
	                        return;
                        },
                        cancel:function(res){
                        	alert('请开启定位授权！');
	                        return;
                        }
                    })
				});
			});
		</script>
        <div class="tangram-suggestion-main" id="tangram-suggestion--TANGRAM__1v-main" data-guid="TANGRAM__1v" style="position: absolute; display: none; left: 15px; top: 54px; width: 1762px;"><div id="tangram-suggestion--TANGRAM__1v" class="tangram-suggestion" style="position:relative; top:0px; left:0px"></div></div>
    </body>  
</html>